<%@page import="com.wanmait.spacesys.vo.Post"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<% 
    String path = request.getContextPath();
%>

<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<script src="<%= path %>/js/jquery-3.6.0.min.js" type="text/javascript"></script>
<meta charset="UTF-8">
<link href="<%=path %>/css/main5152.css" rel="stylesheet">
<style>
	.pagernum{
		margin:10px;
		font-size: 15px;
		cursor: pointer;
	}
</style>
<jsp:include page="/inc/header.jsp"></jsp:include>
    <div class="page-container">
        <div class="container">
            <div class="row">
                <div class="span8 page-content">
                    <div class="row separator">
                    	<div id="result">
	                      <%-- 在这里ajax局部刷新文章列表 --%>
                        </div>  
                    </div>
                    <div class="pager">
	                        <c:forEach begin="1" end="${count/8+(count%8==0?0:1) }" var="i">
	                        	<a class="pagernum" data-page="${i }">${i }</a>
	                        </c:forEach>
                	</div>
                </div>
                <aside class="span4 page-sidebar">
                    <section class="widget">
                        <div class="support-widget">
                            <h3 class="title"><a href="<%= path %>/web/release.jsp">我要发布</a></h3>
                            <p class="intro">一起和航友们来分享你的见解吧~</p>
                        </div>
                    </section>
                </aside>
            </div>
        </div>
    </div>
<script type="text/javascript">
	var path = "${pageContext.request.contextPath}";
	$(function(){
		$("div.pager a").click(function(){
			getPageData($(this).data("page"));
		});
		$("#result").load(path+"/PostController?action=ajaxlist&pageNum=1");
	});
		
	function praised(id,but){	//帖子Id
		var user = "${userinfo.username}";
		var praisedBoolean = $(".like-count").attr("praise");
		console.log("*"+praisedBoolean+"*");
		if(user==""){
			location.href=path+"/web/userLogin.jsp";
		} 
		else{
			if(praisedBoolean=="false"){	//等于false去执行点赞加一的方法
				$(this).load(path+"/PostController?action=praised&id="+id)
				$(but).html($(but).html()*1+1);
				$(".like-count").attr("praise","true");
			}
			else{	//等于true去执行取消点赞的方法
				$(this).load(path+"/PostController?action=cancelPraised&id="+id)
				$(but).html($(but).html()*1-1); 
				$(".like-count").attr("praise","false");
			}
		}
	}
	function getPageData(pageNum){
		$("#result").load(path+"/PostController?action=ajaxlist&pageNum="+pageNum);
	}

</script>
 <jsp:include page="/inc/footer.jsp"></jsp:include>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 